﻿using AutoMapper;
using Domain.Entity;
using Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.ERService
{
	public class ERService : IERService
	{
		private readonly IERRepository eRRepository;
		private readonly IMapper mapper;

		public ERService(IERRepository eRRepository, IMapper mapper)
		{
			this.eRRepository = eRRepository;
			this.mapper = mapper;
		}
		public Task<bool> AddER(ERDto e)
		{
			ER er = mapper.Map<ER>(e);
			return eRRepository.AddER(er);
		}

		public Task<bool> DeleteER(int e)
		{
			return eRRepository.DeleteER(e);
		}

		public List<ER> GetAllERId(int id)
		{
			return eRRepository.GetAllERId(id);
		}

		public List<ER> GetER()
		{
			return eRRepository.GetER();
		}

		public List<ER> GetERName(string name)
		{
			return eRRepository.GetERName(name);
		}

		public List<ER> GetERTiaoJ(string? humanName, string? hunmaMajorName, string? humanMajorKindName, DateTime? startDate, DateTime? endDate)
		{
			return eRRepository.GetERTiaoJ(humanName, hunmaMajorName, humanMajorKindName, startDate, endDate);
		}

		public List<ER> GetERYouxiaoJianl(string? PassPassComment, string? humanName, string? hunmaMajorName, string? humanMajorKindName, DateTime? startDate, DateTime? endDate)
		{
			return eRRepository.GetERYouxiaoJianl(PassPassComment, humanName, hunmaMajorName,humanMajorKindName, startDate, endDate);
		}

		public Task<bool> UpdateER(ERDto e)
		{
			ER er = mapper.Map<ER>(e);
			return eRRepository.UpdateER(er);
		}

		public Task<bool> UpdateERTuijian(ERDto e)
		{
			ER er = mapper.Map<ER>(e);
			return eRRepository.UpdateERTuijian(er);
		}

		public Task<bool> UpdateERMianshi(ERDto e)
		{
			ER er = mapper.Map<ER>(e);
			return eRRepository.UpdateERMianshi(er);
		}

		public Task<bool> UpdateERLuyong(ERDto e)
		{
			ER er = mapper.Map<ER>(e);
			return eRRepository.UpdateERLuyong(er);
		}
	}
}
